package com.masterlu.leetcode.everyday.linkedlist.medium;

/**
 * 力扣题目编号92
 * 反转链表
 * https://leetcode-cn.com/problems/reverse-linked-list-ii/
 *
 * @Author：masterlu
 * @Date：2021/3/18 10:27 上午
 */
public class M92ReverseLinkedList {


    public static void main(String[] args) {

        MyLinkedList<Integer> list = new MyLinkedList<>();
        list.add(1);
        list.add(2);

        System.out.println(list);


    }


    /**
     * 原始反转链表
     *
     * @param head
     */
    private void reverseLinkedList(MyLinkedList.Node head) {

        MyLinkedList.Node pre = null;
        MyLinkedList.Node tmp = null;

        while (head.next != null){

        }


    }


    /**
     * 链表
     */

    static class MyLinkedList<T>{

        private Node head;
        private Node current;

        public MyLinkedList (){

            head = new Node();
        }

        public boolean add(T t){

            Node<T> node = new Node<>(t);
            if (current == null){
                head.next = node;
                current = node;
            }else {
                current.next = node;
                current = node;
            }

            return Boolean.TRUE;
        }


        public void reverse(MyLinkedList list){
            Node curr = list.head.next.next;
            Node tmp =curr.next;
            while (tmp.next != null){
                curr.next = head.next;
                head.next = curr;
                curr = tmp;
                tmp = curr.next;



            }
        }





        static class Node<T> {
            private T value;
            private Node<T> next;

            public Node() {
            }

            public Node(T value) {
                this.value = value;
            }

            public Node(T value, Node<T> next) {
                this.value = value;
                this.next = next;
            }
        }
    }


}
